﻿//初始化左侧 
function InitLeftMenu(data) {
    $(".easyui-accordion").empty();
    var menulist = "";
    menulist+='<div id="aa"  iconCls="icon-print" class="easyui-accordion" fit="true" border="false" >';
    $.each(data, function(i, n) {
    	if(n.type=='url'){
	        menulist += '<div  iconCls="icon-print" title="'+n.text+'" style="overflow:hidden;">';
			menulist += '<ul >';
	        $.each(n.children, function(j, o) {
	        	if(o.type=='url'&&(o.checked)) {
	        		var icon = (o.icon == null || o.icon == '') ? 'iconCls="icon-default-menu"' : 'iconCls="' + o.icon + '"';
	        		menulist += '<li  ' + icon + ' onclick=setmain("'+o.text+'","'+o.attributes+'")  style="cursor: pointer;" >' + o.text + '</li> ';
	        	}
	        });
	        menulist += '</ul></div>';
    	}
    });
    menulist+='</div>';
	$(".easyui-accordion").append(menulist);
	$(".easyui-accordion").accordion();
}
function setmain(title,href){
	href =selfPath+ href.substring(0,href.length-1);
	$(".combo-panel").parent(".panel").remove(); //清楚所有class为combo-panel的class为panel的父元素，解决combobox在页面缓存的问题
	var centerURL = href;
	var centerTitle = title;
	$('#centerId').children().remove();
	$('body').layout('panel','center').panel({
		title:"所在位置："+centerTitle,
		href:centerURL
	});
	$('body').layout('panel','center').panel('refresh');
	return false;		
}

jQuery.ajaxSetup({cache:false});//ajax不缓存
//弹出窗口
function showWindow(options){
	var div = $('<div id="MyPopWindow" modal="true" shadow="false" minimizable="false" cache="false" maximizable="false" collapsible="false" resizable="false" style="margin: 0px;padding: 0px;overflow: auto;"></div>').appendTo($('body'));
	options.onClose = options.onClose || function(){
		$(this).window('destroy');
	};
	$(div).window(options);
}
//关闭弹出窗口
function closeWindow(){
	$("#MyPopWindow").window('close');
}
function _changePassword(){
	var div = $('<div id="_changePass"></div>').appendTo($('body'));
	$(div).window({
		title: '修改密码',
		width: 700,
		height:390,
		href:selfPath+'/user/changePasswordPopWindow',
		collapsible : false,
		resizable : false,
		minimizable : false,
		maximizable : false,
		onClose : function(){
			$(this).window('destroy');
		}
	});
}
function _reLogin(){
	window.location.href="logout";
}
function _logout(){
	window.location.href=selfPath+"/user/logout";
}
function _toIndex(){
	setmain("首页","/aaa/index*");
}
function doPrint()
{
	setmain('报表统计','/aba/cardProcUser*');
}